﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.IO;
using AppToolkit.WPF.Utils;

namespace AppToolkit.WPF.Tests.Utils
{
    [TestFixture]
    public class PathUtilsTests
    {

        [Test]
        public void SplitPath_path_with_blanks()
        {
            string p = @"d:\Test Pfad mit Blanks\XXX";
            string[] res = PathUtils.SplitPath(p);

            Assert.AreEqual(3, res.Length);
            Assert.AreEqual("d:\\", res[0]);
            Assert.AreEqual("Test Pfad mit Blanks", res[1]);
            Assert.AreEqual("XXX", res[2]);
        }

        [Test]
        public void SplitPath_path_with_blanks_alternative_seperators()
        {
            string p = @"d:/Test Pfad mit Blanks/XXX";
            string[] res = PathUtils.SplitPath(p);

            Assert.AreEqual(3, res.Length);
            Assert.AreEqual("d:\\", res[0]);
            Assert.AreEqual("Test Pfad mit Blanks", res[1]);
            Assert.AreEqual("XXX", res[2]);
        }

        [Test]
        public void SplitPath_relative_path_with_blanks()
        {
            string p = @"Test Pfad mit Blanks\XXX";
            int cnt = Environment.CurrentDirectory.Split(new char[]{Path.DirectorySeparatorChar}).Length;
            string[] res = PathUtils.SplitPath(p);

            Assert.AreEqual(cnt+2, res.Length);
            Assert.AreEqual("Test Pfad mit Blanks", res[cnt]);
            Assert.AreEqual("XXX", res[cnt+1]);
        }
    }
}
